import {computed, ref,  defineComponent, h } from 'vue'
// import  Circle from './components/Circle'
import startPage from './pages/startPage'
import gamePage from './pages/gamePage'
import endPage from './pages/endPage'

export default defineComponent({
  setup(props, ctx) {
    // 设置响应式的数据  
    let currentPageName = ref('gamePage')
    let currentPage = computed(()=> {
      if (currentPageName.value === 'startPage') {
        return  startPage
      } 
      if (currentPageName.value === 'gamePage') {
        return gamePage
      }
      if (currentPageName.value === 'endPage') {
        return endPage
      }
    })  

    return {
      currentPageName,
      currentPage
    }
  },
  render(ctx) {
    // const vnode = h('rect', {x: 100, y:100, width: 200, height: 200}, ["大春哥BB", h(Circle) ])
    // 给子组件绑定数据 
    const vnode = h('Container', [h(ctx.currentPage, {onChangePage: function (page) {
      console.log('page:', page);
      ctx.currentPageName = page
    }})])
    // const vnode = h('Container', [h(gamePage)])
    return vnode
  }
})